﻿using QuanLyChoVayCaNhan.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuanLyChoVayCaNhan.Classes
{
    public class Activity
    {
        private static Activity INSTANCE = new Activity();
        public static Activity GetInstance()
        {
            return INSTANCE;
        }

        public void Start()
        {
            WindowsManager.GetInstance().ShowFirstWindow();
        }

        public void Exit()
        {
            Application.Exit();
        }

        public bool Login(string maNV, string password)
        {
            if (UserManager.GetInstance().Login(maNV, password))
            {
                WindowsManager.GetInstance().LoggedInAndShowMainForm();
                return true;
            }
            return false;
        }

        public HoSo CopyHoSo(HoSo hoSo)
        {
            if (hoSo == null) return null;
            HoSo hs = new HoSo()
            {
                MaHS = hoSo.MaHS,
                MaKH = hoSo.MaKH,
                TenKH = hoSo.TenKH,
                SoCMND = hoSo.SoCMND,
                NgayCap = hoSo.NgayCap,
                NoiCap = hoSo.NoiCap,
                DiaChi = hoSo.NoiCap,
                DienThoai = hoSo.DienThoai,
                MaNVQHKH = hoSo.MaNVQHKH,
                IsDayDu = hoSo.IsDayDu,
                SoTienVay = hoSo.SoTienVay,
                ThoiHanVay = hoSo.ThoiHanVay,
                LaiXuatVay = hoSo.LaiXuatVay,
                Created = hoSo.Created,
                Modified = hoSo.Modified,
                SoThamDinh = hoSo.SoThamDinh,
                NgayThamDinh = hoSo.NgayThamDinh,
                MaNVCBTDTD = hoSo.MaNVCBTDTD,
                NangLucPLDSHVDS = hoSo.NangLucPLDSHVDS,
                MucDichSDVV = hoSo.MucDichSDVV,
                KhaNangTC = hoSo.KhaNangTC,
                TinhKhaThiHQDA = hoSo.TinhKhaThiHQDA,
                TSDamBaoTV = hoSo.TSDamBaoTV,
                YKienCBTD = hoSo.YKienCBTD,
                YKienGiamDoc = hoSo.YKienGiamDoc,
                SoToTrinh = hoSo.SoToTrinh,
                NgayLapToTrinh = hoSo.NgayLapToTrinh,
                LoaiTinDung = hoSo.LoaiTinDung,
                DeXuat = hoSo.DeXuat,
                TrangThai = hoSo.TrangThai,
                KhachHang = hoSo.KhachHang,
                NhanVienQHKH = hoSo.NhanVienQHKH,
                NhanVienCBTDTD = hoSo.NhanVienCBTDTD,
                TaiSans = hoSo.TaiSans,
                TiepNhanHS = hoSo.TiepNhanHS
            };
            return hs;
        }
        public TaiSan CopyTaiSan(TaiSan taiSan)
        {
            if (taiSan == null) return null;
            TaiSan ts = new TaiSan()
            {
                SoTSTC = taiSan.SoTSTC,
                NgayDinhGia = taiSan.NgayDinhGia,
                MaHS = taiSan.MaHS,
                MaTS = taiSan.MaTS,
                TenTS = taiSan.TenTS,
                GiaTri = taiSan.GiaTri,
                MaNVHTQHKH = taiSan.MaNVHTQHKH,
                Created = taiSan.Created,
                Modified = taiSan.Modified,
                HoSo = taiSan.HoSo,
                NhanVienHTQHKH = taiSan.NhanVienHTQHKH
            };
            return ts;
        }

        public void Logout()
        {
            UserManager.GetInstance().Logout();

            WindowsManager.GetInstance().LogoutAndShowLoginForm();
        }
    }
}
